![]() |
PATH![]() |
The functions here provide a mechanism for the hub driver to inform the USB Manager of the addition of a new device to a specified USB and to retrieve the USB device ID of the new USB device. The USB hub driver tasks include assigning the device address and preparing the device's default pipe for use. This is the process of enumerating a device for use on the USB.
The functions in this section are called in a specific sequence to perform proper device enumeration on the USB. The function calling sequence is as follows:
The USBHubAddDevice function informs the USB that the hub driver has a new device that needs to be added to the USB.
At the time the device first appears on the USB, it has not yet been reset. When the completion routine for this function is called, it is safe for the hub driver to reset the device. The hub driver should then read the device descriptor to get the endpoint and maxpacket size. The driver must then call the USBHubSetAddress function, even if an error occurs. There is a 1 second timeout allowed, if USBHubSetAddress is not called, it will be called for you. This is done to prevent the bus enumeration mechanism from halting further system activity.
OSStatus USBHubAddDevice(USBPB *pb);
Required fields in the USBPB parameter block for the USBHubAddDevice function are
The device reference can be used to address the device while it is device 0. This reference becomes invalid as soon as it is addressed with the USBHudSetAddress function.
There must be a valid USBReference passed in the usbReference field of the parameter block. If a nil value or a reference that does not match an existing device, interface, or pipe is passed in, the call returns immediately with an unknown device error.
If the device associated with this call is unplugged and its driver removed while this function call is pending, the function will not complete.
The USBHubConfigurePipeZero function must be called after a device is reset, and before any attempt is made to communicate with the device at its default address zero.
OSStatus USBHubConfigurePipeZero(USBPB *pb);
Required fields in the USBPB parameter block for the USBHubConfigurePipeZero function are
The USBHubSetAddress function addresses the currently unaddressed device (The device has been reset and is responding as device 0.) and creates a device reference for it. After this function completes, the device can be addressed with device requests using the new device reference.
OSStatus USBHubSetAddress(USBPB *pb);
Required fields in the USBPB parameter block for the USBHubSetAddress function are
The USBHubDeviceRemoved function causes all pipes open to the specified device to be closed, thus removing the device.
OSStatus USBHubDeviceRemoved(USBPB *pb);
Required fields in the USBPB parameter block for the USBHubDeviceRemoved function are
The hub driver should also call the USBExpertRemoveDeviceDriver function to inform the USB Manager. This removes the class driver associated with the device. If the device is a hub, the hub driver should make the device removal calls for all devices attached to the hub. The USB Manager is responsible for determining what if any downstream devices are connected to the hub and disconnecting them to remove that hub's tree of devices.
Previous | Back Up One Level | Next |